package com.utc.cards.games;

import java.util.HashSet;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;

import com.utc.cards.games.blackjack.BlackJack;
import com.utc.cards.games.damedepique.DameDePique;
import com.utc.cards.games.poker.Poker;
import com.utc.cards.games.septfamilles.SeptFamilles;
import com.utc.cards.games.tarot.Tarot;
import com.utc.cards.games.uno.Uno;
import com.utc.cards.model.game.IGame;

/**
 * Contient tous les jeux, seul endroit où sont utilisés les constructeurs des jeux
 * 
 * @author Arnaud
 * 
 */
public class GameContainer
{
    private static Set<IGame> games;
    private static SortedSet<String> gameNames;

    static
    {
        games = new HashSet<IGame>();
        gameNames = new TreeSet<String>();
        addGame(new DameDePique());
        addFakeGame();
    }

    private GameContainer()
    {
    }

    public static void addGame(IGame game)
    {
        games.add(game);
        gameNames.add(game.getName());
    }

    public static void addFakeGame()
    {
        games.add(new BlackJack());
        gameNames.add("BlackJack");
        games.add(new Poker());
        gameNames.add("Poker");
        games.add(new SeptFamilles());
        gameNames.add("Sept Familles");
        games.add(new Tarot());
        gameNames.add("Tarot");
        games.add(new Uno());
        gameNames.add("Uno");
    }

    // for PLAYER and HOST
    // PLAYER to load the playerGameActivity implementation
    // HOST to load the hostGameActivity implementation
    // and the rules implementation by RulesAgent
    public static IGame getGameByName(String name)
    {
        for (IGame game : games)
        {
            if (game.getName().equals(name))
            {
                return game;
            }
        }
        return null;
    }

    // for HOST when app is launched
    public static SortedSet<String> getCompleteGameNameList()
    {
        return gameNames;
    }

    public static Set<IGame> getGames()
    {
        return games;
    }
}
